#调用OpenAI的生成模型生成回答。

from openai import OpenAI

class OpenAIClient:
    def __init__(self, api_key,base_url):
        self.client = OpenAI(api_key=api_key, base_url=base_url)

    def get_completion(self,prompt, model="qwen-omni-turbo"):
        '''封装openai接口'''
        messages = [
            {
                "role": "user",
                "content": prompt
            }
        ]
        response = self.client.chat.completions.create(
            model=model,
            messages=messages,
            temperature=0.3,
            # 设置输出数据的模态，当前支持两种：["text","audio"]、["text"]
            modalities=["text"],
            # audio={"voice": "Cherry", "format": "wav"},
            # stream 必须设置为 True，否则会报错
            stream=True
        )
        # return response.choices[0].message.content
        return response